<?php
	require_once ('../lib/php/jpgraph/jpgraph.php');
	require_once ('../lib/php/jpgraph/jpgraph_pie.php');
	require_once ('../lib/php/jpgraph/jpgraph_pie3d.php');
	
	require_once "../db/mysql/tbr.php";
	require_once "../classes/forms.cls.php";
	require_once "../conf/config.php";
	require_once('../'.$LANG_FILE);
	/****  CONNECTION TO RDBMS SERVER ****/	
	require_once "../db/mysql/tbr.ini.php";
	/***********************************/
	$base = new base();
	$formDataTable = "svq_formdata";
	$fid  = $_REQUEST['fsid']; 
	$indic = svq_form::formExecIndicator($base,$formDataTable,$fid);
	$title = $indic[0][0];
	$data  = array();
	$legends = array();	
	$rst='<table>';
	foreach($indic as $i){
		$data[] = $i[5];
		$legends[] = $i[1];
		$rst.='<tr>';
		$rst.='<td>';
		$rst.=$i[1];
		$rst.='</td>';
		$rst.='<td>';
		$rst.='</td>';
		$rst.='<td>';
		$rst.=$i[5].' %';
		$rst.='</td>';
		$rst.='</tr>';
	}
	$rst.='</table>';	
	    //$data = array(40,60,21,33);
		$graph = new PieGraph(420,200);
		$graph->SetShadow();
		$graph->title->Set($title);
		$graph->title->SetFont(FF_FONT2,FS_BOLD,34);
		$graph->title->SetColor("darkblue");
		$graph->legend->Pos(0.1,0.2);
		
		$p1 = new PiePlot3D($data);
		$p1->SetTheme("sand");
		$p1->SetCenter(0.4);
		$p1->SetSize(0.4);
		$p1->SetHeight(10);
		// Adjust projection angle
		$p1->SetAngle(45);
		
		//$p1->value->SetFont(FF_ARIAL,FS_NORMAL,10);

		//$p1->SetLegends($gDateLocale->GetShortMonth());
		$p1->SetLegends($legends);		
		// Explode all slices 
		$p1->ExplodeAll(10); 
		
		// Add drop shadow 
		$p1->SetShadow(); 
		$graph->Add($p1);
		$gdImgHandler = $graph->Stroke(_IMG_HANDLER);
		
		// Default is PNG so use ".png" as suffix
		$fileName  = "../lib/php/jpgraph/tmp/".$fid.".png";
		$fileName2 = explode('lib',$fileName);
		$graph->img->Stream($fileName);
	    //$graph->Stroke();
?>
		<?php echo $rst; ?>
		<img src="<?php echo $fileName[0]."/lib/php/jpgraph/tmp/".$fid.".png"; ?>" border=0 />
		